{% extends "layout/indexLayout.htm"%}
{% block head %}
<script type="text/javascript" src="../js/RowExpander.js"></script>
<script type="text/javascript"><!--
function init(){
    document.getElementById("msg_header").className='active';
	
    Ext.define('yoModel', {
        extend: 'Ext.data.Model',
        fields: ['content', 'title', 'date','fromUser','toUser']
    });

    var store = Ext.create('Ext.data.Store', {
        model: 'yoModel',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: '/msg?json=json',
            reader: {
                type: 'json',
                root: 'items',
                totalProperty: 'totalCount'
            }
        }
    });

    var grid = Ext.create('Ext.grid.Panel', {
        store: store,
        columns: [
			{text: "fromUser", width: 100, dataIndex: 'fromUser', sortable: true},     
            {text: "content",width: 500,dataIndex: 'content', sortable: true},
            {text: "title", width: 200, dataIndex: 'title', sortable: true},
            {text: "date", width: 200, dataIndex: 'date', sortable: true},
            {text: "toUser", width: 100, dataIndex: 'toUser', sortable: true}   
        ],
        autoWidth: true,
        autoHeight: true,
        height:600
    });
  
    var main = new MainPanel({
	     region:'center',
	     html:'<div id="grid_div" ></div>'
	});

	var tb = Ext.create('Ext.toolbar.Toolbar');
    tb.suspendLayout = true;
    tb.render('grid_div');
    tb.add({
        icon: 'list-items.gif', // icons can also be specified inline
        text:'发送消息',
        cls: 'x-btn-icon',
        tooltip: '发送消息给其他人',
        handler: function(){
           window.location.href="/addMsg";
        }
    }, '-');
    tb.add({
        icon: 'list-items.gif', // icons can also be specified inline
        text:'收件箱',
        cls: 'x-btn-icon',
        tooltip: '收件箱',
        handler: function(){
	    	var _p={start:0,limit:100,json:'json',type:'toUser'};
			store.load({params:_p});
        }
    }, '-');
    tb.add({
        icon: 'list-items.gif', // icons can also be specified inline
        text:'已发送',
        cls: 'x-btn-icon',
        tooltip: '已发送的消息',
        handler: function(){
			var _p={start:0,limit:100,json:'json',type:'fromUser'};
			store.load({params:_p});
        }
    }, '-');
    grid.render('grid_div');
}
function renderAction(value,cellmeta,record,rowIndex,columnIndex,store){
	return "-";
} 
--></script>
{% endblock %}

{% block body %}

{% endblock %}